<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla controllerform library
jimport('joomla.application.component.controllerform');
 
/**
 * HelloWorld Controller
 */
class ShopControllerEmployer extends JControllerForm
{

	public function save()
	{
		$user		= JFactory::getUser();
		$db =& JFactory::getDBO();
		JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
		$row = JTable::getInstance('Employer','ShopTable');
		$row->bind(JRequest::get('post'));
		
		///--- insert new params
		$text = JRequest::getVar( 'text', '', 'post', 'string', JREQUEST_ALLOWRAW );
		$row->text = $text;
		$row->company = JRequest::getVar('company');
		$row->catid = JRequest::getVar('catid');
		$started = JRequest::getVar('started');
		$t1 = strtotime($started);
		$d1 = date('Y-m-d',$t1);
		$row->started = $d1;
		$finished = JRequest::getVar('finished');
		$t2 = strtotime($finished);
		$d2 = date('Y-m-d',$t2);
		$row->finished = $d2;

		if($row->store())
		{
			$this->setMessage(JText::_('COM_SHOP_METHOD_SAVE_SUCCESS'));
			$this->setRedirect('index.php?option=com_shop&view=employers');
		}
		else
		{
			$this->setMessage(JText::_('COM_SHOP_METHOD_SAVE_FAIL'));
			$this->setRedirect('index.php?option=com_shop&view=employers');
		}
	}
	public function getNumberInString($text) {
            $string = preg_replace('/[^0-9]/', '', $text);
        	return $string;
    }
}
